<?php

namespace app\common\model\mysql;

use think\Model;

class OrderOweBarrelsTicket extends Model
{
    // 设置当前模型对应的完整数据表名称
    protected $table = 'or_order_owe_barrels_ticket';

    /**
     * 查询欠桶欠票数据列表
     * @param array $where
     * @param string $field
     * @return OrderProductWater[]|array|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function getNormalOweBarrelsTicket(array $where = [], string $field = "*"){
        $order = [
            "id" =>"asc",
        ];
        $result = $this->where($where)->field($field)->order($order)->select();
        return $result->toArray();
    }

    /**
     * 删除欠桶欠票数据
     * @param $where
     * @return bool
     */
    public function deleteAllNormalOweBarrelsTicket($where){
        return $this->where($where)->delete();
    }

    /**
     * 添加欠桶欠票数据
     * @param $data
     * @return mixed
     * @throws \think\Exception
     */
    public function addNormalOweBarrelsTicket($data){
        $this->save($data);
        return $this->id;
    }
}
